<template>
	<view>
		<!-- 头部 -->
		<view class="header">
			<view class="user">
				<!-- 头像 -->
				<view class="avatar">
					<image class="user-avatar" src="https://img.js.design/assets/smartFill/img321164da746310.jpg"
						mode="aspectFill">
					</image>
				</view>
				<!-- 用户名 -->
				<text class="user-name">{{userInfo.nickname || '匿名用户'}}</text>
			</view>
		</view>

		<!-- 主体 -->
		<view class="body">
			<view class="menu-container">
				<text class="menu-title">基本信息</text>
				<view class="menu-list">
					<view class="menu-item">
						<text>用户ID</text>
						<view style="display: flex; flex-direction: row; align-items: center;">
							<text>{{userInfo.id}}</text>
							<image style="width: 30rpx;height: 30rpx;margin-left: 16rpx;margin-top: 3rpx;"
								src="../../static/copy.png" mode=""></image>
						</view>
					</view>
					<view class="divier"></view>
					<view class="menu-item">
						<text>提问次数</text>
						<view style="display: flex; flex-direction: row; align-items: center;">
							<text>{{userInfo.money_times}}</text>
							<image style="width: 30rpx;height: 30rpx;margin-left: 16rpx;margin-top: 3rpx;"
								src="../../static/money.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
			<view class="menu-container">
				<text class="menu-title">次数说明</text>
				<view class="menu-list">
					<view class="menu-item">
						<text>登录</text>
						<view style="display: flex; flex-direction: row; align-items: center;">
							<text>+1</text>
							<image style="width: 30rpx;height: 30rpx;margin-left: 16rpx;margin-top: 3rpx;"
								src="../../static/money.png" mode=""></image>
						</view>
					</view>
					<view class="divier"></view>
					<view class="menu-item">
						<text>提问</text>
						<view style="display: flex; flex-direction: row; align-items: center;">
							<text>-1</text>
							<image style="width: 30rpx;height: 30rpx;margin-left: 16rpx;margin-top: 3rpx;"
								src="../../static/money.png" mode=""></image>
						</view>
					</view>
					<view class="divier"></view>
					<view class="menu-item">
						<text>绘画</text>
						<view style="display: flex; flex-direction: row; align-items: center;">
							<text>-1</text>
							<image style="width: 30rpx;height: 30rpx;margin-left: 16rpx;margin-top: 3rpx;"
								src="../../static/money.png" mode=""></image>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const memberApi = require("@/api/memberApi");

	export default {
		data() {
			return {
				userInfo: {},
			}
		},
		onLoad() {
			memberApi.profile().then(res => {
				console.log(res);
				if (res.code != 0) {
					// 未登录
					uni.navigateTo({
						url: '/pages/loginIn/loginIn'
					})
				} else {
					const user = res.data;
					getApp().globalData.userInfo = user;
					this.userInfo = user;
				}
			})
		},
		methods: {

		}
	}
</script>

<style>
	page {
		background-color: #F8F9FB;
	}

	.divier {
		width: 628rpx;
		height: 2rpx;
		background-color: #EEEEEE;
		margin: 0 auto;
	}

	.header {
		width: 750rpx;
		height: 280rpx;
		background-image: url(https://img.js.design/assets/img/640b4e4132b3865687f2ab1e.png);
	}

	.user {
		display: flex;
		flex-direction: row;
		align-items: center;

		padding-top: 150rpx;
		margin-left: 34rpx;
	}

	.user-avatar {
		width: 96rpx;
		height: 96rpx;
		border-radius: 50%;
	}

	.user-name {
		font-size: 32rpx;
		font-weight: 400;
		color: #000000;

		margin-left: 34rpx;
	}

	.body {
		width: 750rpx;

		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.menu-container {
		display: flex;
		flex-direction: column;

		margin-top: 12rpx;
		margin-bottom: 66rpx;
	}

	.menu-list {
		width: 680rpx;
		border-radius: 10rpx;
		background-color: #FFFFFF;

		margin-top: 12rpx;
	}

	.menu-title {
		font-size: 28rpx;
		font-weight: 400;
		color: #000000;

		margin-bottom: 12rpx;
	}

	.menu-item {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;

		padding: 32rpx 26rpx;
	}
</style>